package io.dy.guarded_extend;

import io.dy.utils.ThreadUtils;

/**
 * @author dmj
 * @date 2024年03月22日 下午5:26
 * 邮递员类 需要知道信件id 信件内容 才能开始送信
 */
public class PostMan extends Thread{

    private final Integer id;

    private final String content;

    public PostMan(Integer id, String content) {
        this.id = id;
        this.content = content;
    }

    @Override
    public void run() {
        GuardedContainer<String> instance = GuardedContainer.getInstance();
        GuardedObject<String> guardedObject = instance.getById(id);
        ThreadUtils.printThreadLog("送信ID:" + id + "内容:" + content);
        guardedObject.generate(content);
    }
}
